<template>
  <div class="member-order-detail" v-if="order">
    <!-- 头部 -->
    <OrderDetailAction :order="order"></OrderDetailAction>
    <!-- 进度 -->
    <DetailSteps :order="order"></DetailSteps>
    <!-- 物流 异步组件用suspense包裹 -->
    <Suspense>
      <template #default>
    <DetailLogistics :order="order" v-if="[3,4,5].includes(order.orderState)"></DetailLogistics>
      </template>
      <template #fallback><div class="loading">Loading...</div></template>
    </Suspense>
    <!-- 信息 -->
    <OrderInfo :order="order"></OrderInfo>
  </div>
</template>

<script>
import { ref } from 'vue'
import OrderDetailAction from './components/detail-action'
import DetailSteps from './components/detail-step.vue'
import DetailLogistics from './components/detail-logistics.vue'
import OrderInfo from './components/detail-info.vue'
import { findOrderDetail } from '@/api/order'
import { useRoute } from 'vue-router'
export default {
  name: 'MemberDetail',
  components: { OrderDetailAction, DetailSteps, DetailLogistics, OrderInfo },
  setup () {
    const route = useRoute()
    const order = ref(null)
    findOrderDetail(route.params.id).then(data => {
      order.value = data.result
    })
    return { order }
  }
}
</script>

<style lang="less" scoped>
.member-order-detail{
  background: #fff;
  height: 100%;
}
.loading {
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 30px;
  background-color: #f5f5f5;
  margin: 30px 50px 0;
}
</style>
